package io.renren.modules.oa.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.oa.entity.OaPlanLogEntity;
import io.renren.modules.oa.service.OaPlanLogService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 值班记录
 *
 * @author ziye
 * @email 524748907@qq.com
 * @date 2018-10-25 11:56:09
 */
@RestController
@RequestMapping("oa/oaplanlog")
public class OaPlanLogController {
	@Autowired
    private OaPlanLogService oaPlanLogService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("oa:oaplanlog:list")
    public R list(@RequestParam Map<String, Object> params){
    	
    	
        PageUtils page = oaPlanLogService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("oa:oaplanlog:info")
    public R info(@PathVariable("id") Long id){
        OaPlanLogEntity oaPlanLog = oaPlanLogService.selectById(id);

        return R.ok().put("oaPlanLog", oaPlanLog);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("oa:oaplanlog:save")
    public R save(@RequestBody OaPlanLogEntity oaPlanLog){
        oaPlanLogService.insert(oaPlanLog);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("oa:oaplanlog:update")
    public R update(@RequestBody OaPlanLogEntity oaPlanLog){
        ValidatorUtils.validateEntity(oaPlanLog);
        oaPlanLogService.updateAllColumnById(oaPlanLog);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("oa:oaplanlog:delete")
    public R delete(@RequestBody Long[] ids){
        oaPlanLogService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
